'''
Author: momochong0
Date: 2021-06-23 23:02:01
LastEditors: momochong0
LastEditTime: 2021-06-23 23:02:46
Description: 要推网络荣誉出品
'''
import requests
from lxml import etree
#构建url
url='https://www.airbnb.cn/s/%E6%88%90%E9%83%BD/homes?refinement_paths%5B%5D=%2Fhomes&screen_size=large&parent_city_place_id=ChIJIXdEACPF7zYRAg4kLs5Shrk&place_id=ChIJIXdEACPF7zYRAg4kLs5Shrk'
# https://www.airbnb.cn/s/%E6%88%90%E9%83%BD/homes?refinement_paths%5B%5D=%2Fhomes&screen_size=large&parent_city_place_id=ChIJIXdEACPF7zYRAg4kLs5Shrk&place_id=ChIJIXdEACPF7zYRAg4kLs5Shrk
for i in range(0,18):
	urlnum=i*18
	link=url+str(urlnum)
	strr=requests.get(link).text#返回网页信息
	tree=etree.HTML(strr)

	name=tree.xpath("//div[@class='_qhtkbey']/text()")	#房源名			
	commentnum=tree.xpath("//*/div[2]/div[1]/div/span[2]/text()")#房源评论数
	price=tree.xpath("//*/div[2]/div[2]/div/div/div[1]/div/span/span/span/span[1]/span[2]/text()")#房源价格
	housetype=tree.xpath("//*/div[2]/a/div/div[1]/div/span/span/text()")#房源类型